Add tiger reads & testsuite.
authorrobertl <robertl>
Thu, 19 Sep 2002 18:28:16 +0000 (18:28 +0000)
committerrobertl <robertl>
Thu, 19 Sep 2002 18:28:16 +0000 (18:28 +0000)
testo
tiger.c

diff --git a/testo b/testo
index 90777e20ba3e2b842fd1ae65020cfa397b1577be..58ced8c71246c54954428a3d62c15527e4296be5 100755 (executable)
--- a/testo
+++ b/testo
@@ -42,6 +42,14 @@ rm -f ${TMPDIR}/mm.mapsource ${TMPDIR}/ms.gps
 # Magellan serial
 # TODO
 
+# Tiger
+# This one is a little tacky, becuase it's a very lossy format.
+# so we simply test we can write it, and then read it and write it and
+# get an identical file back.
+rm -f ${TMPDIR}/tiger
+${PNAME} -i geo -f geocaching.loc -o tiger -F ${TMPDIR}/tiger
+${PNAME} -i tiger -f ${TMPDIR}/tiger -o tiger -F ${TMPDIR}/tiger2
+diff ${TMPDIR}/tiger ${TMPDIR}/tiger2
 
 # CSV (Comma separated value) data.
 
diff --git a/tiger.c b/tiger.c
index 4100a5290d08f3141c209b2932e018ecaec06133..faf5efb0d49d0bc5469aae30bb63dafb59ad4808 100644 (file)
--- a/tiger.c
+++ b/tiger.c
@@ -60,34 +60,22 @@ wr_deinit(void)
 static void
 data_read(void)
 {
-abort();
-#if 0
-       char name[9], desc[30];
        double lat,lon;
-       char latdir, londir;
-       long alt; 
-       char alttype;
-       char icon[3] = {0};
+       char desc[100];
+       char icon[100];
        waypoint *wpt_tmp;
 
-       while( fscanf(file_in, "%s %le%c %le%c %ld%c %30[^,] %c",
-                       name, &lat, &latdir, &lon, &londir,
-                       &alt, &alttype, desc, icon) > 0) {
-               wpt_tmp = xcalloc(sizeof(*wpt_tmp),1);
-               wpt_tmp->position.altitude.altitude_meters = alt;
-               wpt_tmp->shortname = xstrdup(name);
-               wpt_tmp->description = xstrdup(desc);
-               wpt_tmp->creation_time = time(NULL);
+       while( fscanf(file_in, "%lf,%lf:%100[^:]:%100[^\n]", 
+                       &lon, &lat, icon, desc) > 0) {
+               wpt_tmp = xcalloc(sizeof (*wpt_tmp), 1);
 
-               if (latdir == 'S') lat = -lat;
-               if (londir == 'W') lon = -lon;
-               wpt_tmp->position.longitude.degrees = lon/100.0;
-               wpt_tmp->position.latitude.degrees = lat/100.0;
-               wpt_tmp->icon_descr = xstrdup(icon);
+               wpt_tmp->position.longitude.degrees = lon;
+               wpt_tmp->position.latitude.degrees = lat;
+               wpt_tmp->description = xstrdup(desc);
+               wpt_tmp->shortname = mkshort(desc);
 
                waypt_add(wpt_tmp);
        }
-#endif
 }
 
 static void